package com.codeoss.framework.view.parser;

import org.springframework.stereotype.Service;

import com.codeoss.framework.view.component.Component;
import com.codeoss.framework.view.component.chart.GaugeComponent;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

@Service("gaugeParser")
public class GaugeComponentParser extends AbstractChartParser {
	protected void setAttributes(IParseContext parseContext, ObjectNode objectNode, Component component) {
		super.setAttributes(parseContext, objectNode, component);
		GaugeComponent gaugeComponent = (GaugeComponent) component;
		ObjectNode propertyMapNode = (ObjectNode) objectNode.get("propertyMap");
		if (propertyMapNode != null) {
			JsonNode jsonNode = propertyMapNode.get("min");
			if(jsonNode!=null) {
				gaugeComponent.setMin(jsonNode.asLong());
			}
			jsonNode = propertyMapNode.get("max");
			if(jsonNode!=null) {
				gaugeComponent.setMax(jsonNode.asLong());
			}
		}
	}
	@Override
	protected Component createComponent(IParseContext parseContext, ObjectNode objectNode) {
		// TODO Auto-generated method stub
		return new GaugeComponent();
	}

}
